package com.shey.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.List;

import com.shey.bean.GroupPhoto;
import com.shey.imageloader.MyImageLoader;
import com.shey.qiuckpictest.R;


/**
 * Created by SheyChen on 2015/12/2 20:52.
 * Email 1768037936@qq.com
 */
public class SubGroupAdapter extends SimpleBaseAdapter<GroupPhoto> {


    public SubGroupAdapter(Context context, List<GroupPhoto> data) {
        super(context, data);
    }

    @Override
    public int getItemResource() {
        return R.layout.item_groupphoto;
    }

    @Override
    public View getItemView(int position, View convertView, ViewHolder holder) {
        ImageView imageView;
        TextView groupName;
        TextView groupSize;

        imageView = holder.getView(R.id.item_group_photo);
        groupName = holder.getView(R.id.item_group_name);
        groupSize = holder.getView(R.id.item_group_size);

        GroupPhoto mGroupPhoto = (GroupPhoto) getItem(position);
        if (mGroupPhoto != null) {
            if (!TextUtils.isEmpty(mGroupPhoto.getPath())) {
                MyImageLoader.getInstance().displayImage(imageView,mGroupPhoto.getPath());
            }
            if (!TextUtils.isEmpty(mGroupPhoto.getGroupName())) {
                groupName.setText(mGroupPhoto.getGroupName());
            }
            groupSize.setText(mGroupPhoto.getPhotoSize() + "");
        }
        return convertView;
    }
}
